﻿using UnityEngine;
using System.Collections;

public class BossLookPlayer : MonoBehaviour {
	[SerializeField] float viewDistance = 5f;
	[SerializeField] float viewAngle = 170f;
	bool playerInsight = false;
	public bool PlayerInsight{ get { return playerInsight; } }
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		Vector3 direction = StaticVarFunc.Player.transform.position - transform.position;
		float dis = direction.magnitude;
		playerInsight = false;
		if (dis < viewDistance) {
			float angle = Vector3.Angle (direction, transform.forward);
			if (angle < viewAngle * 0.5f) {               
				RaycastHit hit;
				if (Physics.Raycast (transform.position, direction.normalized, out hit, viewDistance)) {
					if (hit.collider.gameObject == StaticVarFunc.Player) {                     
						playerInsight = true;
					}
				}
			}
		}
	}
}
